// pages/businessdetails/businessdetails.js
var app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    inputShowed: false,
    inputVal: "",
    markers: [],
    lng:'',
    lat:'',
    polyline: [],
    domHeight:'',
    controls: [{
      id: 1,
      iconPath: '/resources/location.png',
      position: {
        left: 0,
        top: 300 - 50,
        width: 50,
        height: 50
      },
      clickable: true
    }]
  },
  regionchange(e) {
    console.log(e.type)
  },
  markertap(e) {
    console.log(e.markerId)
  },
  controltap(e) {
    console.log(e.controlId)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this;
    wx.getSystemInfo({
      success: function (res) {
        console.log(res.windowHeight);
        that.setData({
          domHeight: res.windowHeight
        })
      },
    })
    this.getBusiness(options);
    var that = this;
    wx.getLocation({
      type: "wgs84",
      success: function (res) {
        var latitude = res.latitude;
        var longitude = res.longitude;

        that.setData({
          latitude: res.latitude,
          longitude: res.longitude,

        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
 
  getBusiness(res) {
    var that=this;
      var markers = [{
        iconPath: '../../static/images/icon/xzz.png',
        id: 0,
        longitude: res.lng,
        latitude: res.lat,
        width: 40,
        height: 40
      }];
      var polyline = [{
        points: [{
          longitude: res.lng,
          latitude: res.lat,
        }, {
            longitude: res.lng,
            latitude: res.lat,
        }],
        color: '#FF0000DD',
        width: 2,
        dottedLine: true
      }]

      that.setData({
        markers: markers,
        polyline: polyline,
        lng: res.lng,
        lat: res.lat

      })
   
  }

})